#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>

using namespace std;

int findPeakElement(const vector<int>& nums) {
    int left = 0, right = nums.size() - 1;
    if (nums.size() == 1)
        return 0;
    while (left <= right)
    {
        int mid = left + (right - left) / 2;
        if (nums[mid] > nums[mid - 1] && nums[mid] > nums[mid + 1])
            return mid;
        else if (mid == 0 && nums[mid] > nums[mid + 1])
            return mid;
        else if (nums[mid] > nums[mid - 1])
            left = mid + 1;
        else
            right = mid - 1;
    }

    return left;
}

int main()
{
    findPeakElement({ 2,1 });
	return 0;
}